AC_INIT([icepac], [0.3.1], [hakuch@gmail.com])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_CONFIG_SRCDIR([src/main.c])

# Check for C Compiler
AC_PROG_CC

#AC_PROG_LIBTOOL
AC_PROG_CXX
LT_INIT

AC_C_CONST
AC_FUNC_CLOSEDIR_VOID
AC_FUNC_ERROR_AT_LINE
AC_FUNC_MALLOC
AC_FUNC_STAT
AC_FUNC_VPRINTF
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_TYPE_SIZE_T

AC_CHECK_LIB([dl], [dlopen], [], [AC_MSG_ERROR([Can't locate libdl.])])

AC_ARG_ENABLE(
    [local],
    [AC_HELP_STRING(
        [--enable-local],
        [Build a local version to ease testing])],
    [])
     
if test $enable_local; then
    libdir="$(pwd)"
    bindir="$(pwd)"
    AC_DEFINE(LOCAL_BUILD, [1], [Is this a local build?])
else
    AC_DEFINE(LOCAL_BUILD, [0], [Is this a local build?])
fi

# Use pkg-config to find lua
PKG_CHECK_MODULES(
    [LUA],
    [lua >= 5.1],
    [],
    [AC_MSG_ERROR($LUA_PKG_ERRORS)])

AC_CONFIG_HEADERS([config.h])

AC_CONFIG_FILES([
    Makefile
    lib/Makefile
    src/Makefile])

AC_OUTPUT
